# -*- encoding:utf-8 -*-
from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
_modified_time = 1288714947.0585799
_template_filename='/Users/joeldunham/old/onlinelinguisticdatabase/templates/derived/form/previoussearches.html'
_template_uri='/derived/form/previoussearches.html'
_template_cache=cache.Cache(__name__, _modified_time)
_source_encoding='utf-8'
from webhelpers.html import escape
_exports = ['heading', 'title']


def _mako_get_namespace(context, name):
    try:
        return context.namespaces[(__name__, name)]
    except KeyError:
        _mako_generate_namespaces(context)
        return context.namespaces[(__name__, name)]
def _mako_generate_namespaces(context):
    pass
def _mako_inherit(template, context):
    _mako_generate_namespaces(context)
    return runtime._inherit_from(context, u'/base/index.html', _template_uri)
def render_body(context,**pageargs):
    context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        url = context.get('url', UNDEFINED)
        c = context.get('c', UNDEFINED)
        range = context.get('range', UNDEFINED)
        len = context.get('len', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 1
        __M_writer(u'\n\n')
        # SOURCE LINE 3
        __M_writer(u'\n')
        # SOURCE LINE 4
        __M_writer(u'\n\n')
        # SOURCE LINE 6
        if c.previousSearches:
            # SOURCE LINE 7
            __M_writer(u'\n<!-- The following formats the previous search terms in human-readable English prose ... more or less-->\n')
            # SOURCE LINE 9
            for i in range(len(c.previousSearches)):
                # SOURCE LINE 10
                searchDict = c.previousSearches[i]['result'] 
                
                __M_locals_builtin_stored = __M_locals_builtin()
                __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['searchDict'] if __M_key in __M_locals_builtin_stored]))
                __M_writer(u'\n<a href="')
                # SOURCE LINE 11
                __M_writer(escape(url(controller='form', action='searchprevious', id=i)))
                __M_writer(u'" title="Click here to repeat or modify this search">\n<h2>')
                # SOURCE LINE 12
                __M_writer(escape(searchDict['timeSearched'].strftime('%b %d, %Y at %I:%M %p')))
                __M_writer(u'</h2>\n<ul>\n    ')
                # SOURCE LINE 14
                content = 0 
                
                __M_locals_builtin_stored = __M_locals_builtin()
                __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['content'] if __M_key in __M_locals_builtin_stored]))
                __M_writer(u'\n')
                # SOURCE LINE 15
                if searchDict['searchTerm1']:
                    # SOURCE LINE 16
                    if searchDict['searchType1'] in ['as a phrase', 'as a reg exp', 'exactly']:
                        # SOURCE LINE 17
                        __M_writer(u'        <li>search expression 1: <span class="emphasize"> &lsquo;')
                        __M_writer(escape(searchDict['searchTerm1']))
                        __M_writer(u'&rsquo; ')
                        __M_writer(escape(searchDict['searchType1']))
                        __M_writer(u' in ')
                        __M_writer(escape(searchDict['searchLocation1']))
                        __M_writer(u'</span></li>\n')
                        # SOURCE LINE 18
                    else:
                        # SOURCE LINE 19
                        __M_writer(u'        ')
                        typeToBoolean = {'any of these': "' or '", 'all of these': "' and '"} 
                        
                        __M_locals_builtin_stored = __M_locals_builtin()
                        __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['typeToBoolean'] if __M_key in __M_locals_builtin_stored]))
                        __M_writer(u'        \n        <li>search expression 1: <span class="emphasize"> ')
                        # SOURCE LINE 20
                        __M_writer(escape(searchDict['searchType1']))
                        __M_writer(u' in ')
                        __M_writer(escape(searchDict['searchLocation1']))
                        __M_writer(u': &lsquo;')
                        __M_writer(escape(typeToBoolean[searchDict['searchType1']].join(searchDict['searchTerm1'].split(' '))))
                        __M_writer(u'&rsquo;</span></li>\n')
                        pass
                    # SOURCE LINE 22
                    __M_writer(u'        ')
                    content += 1 
                    
                    __M_locals_builtin_stored = __M_locals_builtin()
                    __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['content'] if __M_key in __M_locals_builtin_stored]))
                    __M_writer(u'\n')
                    pass
                # SOURCE LINE 24
                if searchDict['searchTerm2']:
                    # SOURCE LINE 25
                    __M_writer(u'        ')
                    booleanTranslator = {'not_':'and not', 'and_': 'and', 'or_': 'or'} 
                    
                    __M_locals_builtin_stored = __M_locals_builtin()
                    __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['booleanTranslator'] if __M_key in __M_locals_builtin_stored]))
                    __M_writer(u'\n')
                    # SOURCE LINE 26
                    if searchDict['searchType2'] in ['as a phrase', 'as a reg exp', 'exactly']:
                        # SOURCE LINE 27
                        __M_writer(u'        <li>search expression 2: <span class="emphasize"> ')
                        __M_writer(escape(booleanTranslator[searchDict['andOrNot']]))
                        __M_writer(u' &lsquo;')
                        __M_writer(escape(searchDict['searchTerm2']))
                        __M_writer(u'&rsquo; ')
                        __M_writer(escape(searchDict['searchType2']))
                        __M_writer(u' in ')
                        __M_writer(escape(searchDict['searchLocation2']))
                        __M_writer(u'</span></li>\n')
                        # SOURCE LINE 28
                    else:
                        # SOURCE LINE 29
                        __M_writer(u'        ')
                        typeToBoolean = {'any of these': "' or '", 'all of these': "' and '"} 
                        
                        __M_locals_builtin_stored = __M_locals_builtin()
                        __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['typeToBoolean'] if __M_key in __M_locals_builtin_stored]))
                        __M_writer(u'\n        <li>search expression 2: <span class="emphasize"> ')
                        # SOURCE LINE 30
                        __M_writer(escape(booleanTranslator[searchDict['andOrNot']]))
                        __M_writer(u' ')
                        __M_writer(escape(searchDict['searchType2']))
                        __M_writer(u' in ')
                        __M_writer(escape(searchDict['searchLocation2']))
                        __M_writer(u': &lsquo;')
                        __M_writer(escape(typeToBoolean[searchDict['searchType2']].join(searchDict['searchTerm2'].split(' '))))
                        __M_writer(u'&rsquo;</span></li>\n')
                        pass
                    # SOURCE LINE 32
                    __M_writer(u'        ')
                    content += 1 
                    
                    __M_locals_builtin_stored = __M_locals_builtin()
                    __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['content'] if __M_key in __M_locals_builtin_stored]))
                    __M_writer(u'\n')
                    pass
                # SOURCE LINE 34
                __M_writer(u'    ')
                restrictors = [restrictor for restrictor in searchDict['restrictors'] if restrictor['options']] 
                
                __M_locals_builtin_stored = __M_locals_builtin()
                __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['restrictor','restrictors'] if __M_key in __M_locals_builtin_stored]))
                __M_writer(u'\n')
                # SOURCE LINE 35
                if restrictors:
                    # SOURCE LINE 36
                    for restrictor in restrictors:
                        # SOURCE LINE 37
                        __M_writer(u'            <li>restrictor: <span class="emphasize">')
                        __M_writer(escape(restrictor['location']))
                        __M_writer(u' ID ')
                        __M_writer(escape(restrictor['containsNot']))
                        __M_writer(u' ')
                        __M_writer(escape(restrictor['allAnyOf']))
                        __M_writer(u' ')
                        __M_writer(escape(', '.join([restrictor or 'empty' for restrictor in restrictor['options']])))
                        __M_writer(u'</span></li>\n')
                        pass
                    # SOURCE LINE 39
                    __M_writer(u'        ')
                    content += 1 
                    
                    __M_locals_builtin_stored = __M_locals_builtin()
                    __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['content'] if __M_key in __M_locals_builtin_stored]))
                    __M_writer(u'\n')
                    pass
                # SOURCE LINE 41
                __M_writer(u'    ')
                dateRestrictors = [restrictor for restrictor in searchDict['dateRestrictors'] if restrictor['date']] 
                
                __M_locals_builtin_stored = __M_locals_builtin()
                __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['restrictor','dateRestrictors'] if __M_key in __M_locals_builtin_stored]))
                __M_writer(u'\n')
                # SOURCE LINE 42
                if dateRestrictors:
                    # SOURCE LINE 43
                    __M_writer(u'        ')
                    relationTranslator = {'not_': 'not', 'earlier_than': 'earlier than', 'later_than': 'later than', '': ''} 
                    
                    __M_locals_builtin_stored = __M_locals_builtin()
                    __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['relationTranslator'] if __M_key in __M_locals_builtin_stored]))
                    __M_writer(u'\n        ')
                    # SOURCE LINE 44
                    locationTranslator = {'dateElicited': 'date elicited', 'datetimeModified': 'date modified', 'datetimeEntered': 'date entered'} 
                    
                    __M_locals_builtin_stored = __M_locals_builtin()
                    __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['locationTranslator'] if __M_key in __M_locals_builtin_stored]))
                    __M_writer(u'\n')
                    # SOURCE LINE 45
                    for restrictor in dateRestrictors:
                        # SOURCE LINE 46
                        __M_writer(u'            <li>date restrictor: <span class="emphasize">')
                        __M_writer(escape(locationTranslator[restrictor['location']]))
                        __M_writer(u' is ')
                        __M_writer(escape(relationTranslator[restrictor['relation']]))
                        __M_writer(u' ')
                        __M_writer(escape(restrictor['date'].strftime('%b %d, %Y')))
                        __M_writer(u'</span></li>\n')
                        pass
                    # SOURCE LINE 48
                    __M_writer(u'        ')
                    content += 1 
                    
                    __M_locals_builtin_stored = __M_locals_builtin()
                    __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['content'] if __M_key in __M_locals_builtin_stored]))
                    __M_writer(u'\n')
                    pass
                # SOURCE LINE 50
                if content is 0:
                    # SOURCE LINE 51
                    __M_writer(u'        <li>Everything</li>\n')
                    pass
                # SOURCE LINE 53
                __M_writer(u'    ')
                directionTranslator = {'asc': 'ascending', 'desc': 'descending'} 
                
                __M_locals_builtin_stored = __M_locals_builtin()
                __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['directionTranslator'] if __M_key in __M_locals_builtin_stored]))
                __M_writer(u'\n    <li>ordered by ')
                # SOURCE LINE 54
                __M_writer(escape(searchDict['orderByColumn']))
                __M_writer(u' ')
                __M_writer(escape(directionTranslator[searchDict['orderByDirection']]))
                __M_writer(u'</li>\n</ul>\n</a>\n<div class="tableSpacerDivHalf"></div>\n')
                pass
            # SOURCE LINE 59
            __M_writer(u'\n')
            pass
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_heading(context):
    context.caller_stack._push_frame()
    try:
        c = context.get('c', UNDEFINED)
        len = context.get('len', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 4
        __M_writer(u'<h1 class="heading">Your ')
        __M_writer(escape(len(c.previousSearches)))
        __M_writer(u' Previous Searches (max ')
        __M_writer(escape(c.maxNoPreviousSearches))
        __M_writer(u')</h1><br />')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_title(context):
    context.caller_stack._push_frame()
    try:
        __M_writer = context.writer()
        # SOURCE LINE 3
        __M_writer(u'Previous Searches')
        return ''
    finally:
        context.caller_stack._pop_frame()


